import time
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.svm import SVC
import plotly.graph_objs as go
from sklearn.model_selection import train_test_split

from sklearn.metrics import accuracy_score
import sklearn.datasets as DATA 
from sklearn.decomposition import PCA

## 设置属性防止中文乱码
mpl.rcParams['font.sans-serif'] = [u'SimHei']
mpl.rcParams['axes.unicode_minus'] = False

## 读取数据
iris=DATA.load_iris()
y=iris.target
x=iris.data
pca=PCA(n_components=2)     #加载PCA算法，设置降维后主成分数目为2
reduced_x=pca.fit_transform(x)#对样本进行降维


## 数据分割
x_train, x_test, y_train, y_test = train_test_split(reduced_x, y, random_state=28, train_size=0.6)

#kernel
kernel_1 = SVC(C=1.0,kernel = 'linear')
kernel_2 = SVC(C=1.0,kernel = 'rbf')
kernel_3 = SVC(C=1.0,kernel = 'poly')
kernel_4 = SVC(C=1.0,kernel = 'sigmoid')

print(x_train.shape,x_test.shape,y_test.shape,y_train.shape)

